<style>
    .btn.btn-default-o{
        border-radius: 1rem;
        line-height: 1.1rem;
        height: 1.2rem;
        padding: 0 1rem;
        font-size: .6rem;
    }
    .towline{
        color: #000;
        font-size: 0.7rem;
        overflow: hidden;
        text-overflow: ellipsis;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        white-space: normal;
    }
    .fui-list-inner .text{
        display: -webkit-box;
        display: -webkit-flex;
        display: -ms-flexbox;
        display: flex;
        -webkit-box-pack:justify;-webkit-justify-content:space-between;-ms-flex-pack:justify;justify-content:space-between;
        font-size: .7rem;
        color: #000;
    }
    .goods-selected .fui-list-inner{
        height: 4rem;
        display: -webkit-box;
        display: -webkit-flex;
        display: flex;
        flex-direction: column;
        -webkit-flex-direction: column;
        justify-content: space-between;
        -webkit-justify-content: space-between;
    }
</style>
<div class="fui-page fui-page page-commission-selectgoods" id="myshop-select-goods">
    <div class="fui-header">
        <div class="fui-header-left">
            <a class="back" ng-click="goback()"></a>
        </div>
        <div class="title">商品列表</div>
    </div>
    <div class="fui-content">
	<div class="fui-fullHigh-group" >    
        <div class="fui-fullHigh-item menu" id="tab">
            <nav ng-class="{'on':pagedata.ctype =='all'}" ng-click="pagedata.getlist('all',0)">全部商品</nav>
			<nav ng-class="{'on':pagedata.ctype =='isnew'}" ng-click="pagedata.getlist('isnew',0)">新上宝贝</nav>
			<nav ng-class="{'on':pagedata.ctype =='isrecommand'}" ng-click="pagedata.getlist('isrecommand',0)">推荐宝贝</nav>
			<div ng-repeat="c1 in pagedata.category">
				<nav ng-class="{'on':pagedata.ctype ==c1.id}" ng-click="pagedata.getlist('',c1.id)" ng-show="!c1.enabled && pagedata.shopset.category.level !='-1'">{{c1.title}}</nav>
				<div ng-repeat="c2 in pagedata.category.childs[c1.id]">
					<nav ng-class="{'on':pagedata.ctype ==c2.id}" ng-click="pagedata.getlist('',c1.id,c2.id)" ng-show="!c2.enabled && pagedata.shopset.category.level>=2">{{c2.title}}</nav>
					<nav ng-repeat="c3 in pagedata.category.childs[c2.id]" ng-class="{'on':pagedata.ctype ==c3.id}" ng-click="pagedata.getlist('',c3.id)" ng-show="!c3.enabled && pagedata.shopset.category.level>=3">{{c3.title}}</nav>
				</div>
			</div>
        </div>
        <div class="fui-fullHigh-item container">
				<div class="fui-cellone" style="padding:0;top:0;">
				 <div class="fui-cellone-info">
					<div class="search-input" style="height:1.6rem">
						<form action="javascript:return true">
						<i id="searchsub" class="icon icon-sousuo1 bold" ng-click="tool.get_list('jy_scrm/goods/getlist/',true);" style="line-height: 1.7rem;"></i>
						<input type="search" placeholder="请输入商品名称" class="search" ng-model="pagedata.params.keyword" style="height:1.6rem;border: 0;text-align: left; color: #999; font-size:0.6rem;background:#f2f2f2;border-radius: 1rem;" />
						</form>
					</div>
				 </div>
				 <div class="fui-cellone-remark noremark">
					<span style="margin-left:0.3rem;font-size: 0.75rem;" ng-click="tool.get_list('jy_scrm/goods/getlist/',true);">搜索</span>
				 </div>
				</div>
				<p ng-if="pagedata.list.length<1" class="text-center text-cancel empty" style="margin-top:2rem;color:#999">暂时没有任何商品</p>
				<div class="fui-list-group goods-list-group" style="margin-top:0;">
					<div ng-repeat="g in pagedata.list" class="fui-list goods-item" style="padding:0.5rem 0">
							<div class="fui-list-media">
								<img ng-src="{{tomedia(g.image) || '../core/resource/images/nopic.jpg'}}" class='round'/>
							</div>
							<div class='fui-list-inner'>
								<div class='subtitle'>{{g.title}}</div>
								<div class='gray' style="font-size:0.6rem">
								<span class='text-danger'>￥{{g.price}}</span>
								<span ng-click="pagedata.send_file(g);" class='label label-success' style="margin-left:1rem">发送商品</span>
								</div>
							</div>
					</div>
				</div>
				<div ng-if="loading" class='infinite-loading'><span class='fui-preloader'></span><span class='text'> 正在加载...</span></div>
        </div> 
    </div>
	</div>
</div>
<script>
scope.pagedata.ctype ='all'
scope.tool.get_list('jy_scrm/goods/getlist/',true);
scope.pagedata.scroll_bottom=function(){
	scope.tool.get_list('jy_scrm/goods/getlist/');
}
scope.pagedata.getlist=function(order,pid,cid){
	if(order){
		scope.pagedata.ctype =order
		scope.pagedata.params.order =order
	}else if(pid){
		scope.pagedata.ctype=pid
		scope.pagedata.params.pid=pid
		if(cid){
			scope.pagedata.params.cid=cid
		}
	}
	scope.tool.get_list('jy_scrm/goods/getlist/',true);
}
</script>
<script>
scope.pagedata.params.type='news';
scope.pagedata.send_file=function(item){
	if(!item || !item.id){
		scope.message('请选择商品！');
		return false;
	}
	if(scope.pagedata.params.type=='news'){
		wx.invoke('sendChatMessage', {
			msgtype:'news',
			news: {
				link: item.h5url, //H5消息页面url 必填
				title: item.title, //H5消息标题
				desc: item.desc, //H5消息摘要
				imgUrl: item.image, //H5消息封面图片URL
			},
		}, function(res) {
			if (res.err_msg == 'sendChatMessage:ok') {
				//发送成功
			}else{
				//console.log(res);
				res.errMsg=res.errMsg?res.errMsg:res.err_msg
				scope.message('发送失败！'+res.errMsg);
			}
		});
	}
}
//手机软键盘--搜索
$("body").keydown(function() {
    if (event.keyCode == "13") {
        $('#searchsub').click();
    }
});
</script>